package com.imooc.collection;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * Created by JiaJia on 2019/6/4 0004.
 */
public class LRUCache<K,V> extends LinkedHashMap<K,V> {
    private static final int MAX_VALUE=3;
    protected boolean removeEldestEntry(Map.Entry eldest){
        return size()>MAX_VALUE;
    }
    LRUCache(){
        super(MAX_VALUE,0.75f,true);
    }

    public static void main(String[] args) {
        LRUCache<Integer,String> cache=new LRUCache<>();
        cache.put(1,"a");
        cache.put(2,"b");
        cache.put(3,"c");
        cache.get(1);
        cache.put(4,"d");
        System.out.println(cache.keySet());
    }

}